package com.leTest.cmsService.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leTest.cmsService.entity.CrmBannerEntity;
import com.leTest.cmsService.mapper.CrmBannerMapper;
import com.leTest.cmsService.service.CrmBannerService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author le
 * @since 2025-02-23
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBannerEntity> implements CrmBannerService {

    //根据id进行降序排列,显示排列之后的前两条记录
    @Override
    public List<CrmBannerEntity> selectAllBanner() {
        QueryWrapper<CrmBannerEntity> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        //使用last方法拼接sql语句
        wrapper.last("limit 2");

        List<CrmBannerEntity> list = baseMapper.selectList(null);
        return list;
    }

}
